package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.DsRegioninfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DsSpecialregion;
import com.ruoyi.system.service.IDsSpecialregionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特殊区域Controller
 * 
 * @author ruoyi
 * @date 2024-06-12
 */
@RestController
@RequestMapping("/system/specialregion")
public class DsSpecialregionController extends BaseController
{
    @Autowired
    private IDsSpecialregionService dsSpecialregionService;

    /**
     * 查询特殊区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:specialregion:list')")
    @GetMapping("/list")
    public TableDataInfo list(DsSpecialregion dsSpecialregion)
    {

        startPage();
        List<DsSpecialregion> list = dsSpecialregionService.selectDsSpecialregionList(dsSpecialregion);
        return getDataTable(list);
    }

    /**
     * 导出特殊区域列表
     */
    @PreAuthorize("@ss.hasPermi('system:specialregion:export')")
    @Log(title = "特殊区域", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsSpecialregion dsSpecialregion)
    {
        List<DsSpecialregion> list = dsSpecialregionService.selectDsSpecialregionList(dsSpecialregion);
        ExcelUtil<DsSpecialregion> util = new ExcelUtil<DsSpecialregion>(DsSpecialregion.class);
        util.exportExcel(response, list, "特殊区域数据");
    }

    /**
     * 获取特殊区域详细信息
     */


    @PreAuthorize("@ss.hasPermi('system:specialregion:query')")
    @GetMapping(value = "/quyu")
    public TableDataInfo getInfo(DsSpecialregion dsRegioninfo)
    {
        //startPage();
        List<DsSpecialregion> list=dsSpecialregionService.selectDsSpecialregionBySpecialId(dsRegioninfo);
        System.out.println(list);
        return getDataTable(list);
    }

    /**
     * 新增特殊区域
     */
    @PreAuthorize("@ss.hasPermi('system:specialregion:add')")
    @Log(title = "特殊区域", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DsSpecialregion dsSpecialregion)
    {
        return toAjax(dsSpecialregionService.insertDsSpecialregion(dsSpecialregion));
    }

    /**
     * 修改特殊区域
     */
    @PreAuthorize("@ss.hasPermi('system:specialregion:edit')")
    @Log(title = "特殊区域", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DsSpecialregion dsSpecialregion)
    {
        return toAjax(dsSpecialregionService.updateDsSpecialregion(dsSpecialregion));
    }

    /**
     * 删除特殊区域
     */
    @PreAuthorize("@ss.hasPermi('system:specialregion:remove')")
    @Log(title = "特殊区域", businessType = BusinessType.DELETE)
	@DeleteMapping("/{specialIds}")
    public AjaxResult remove(@PathVariable Long[] specialIds)
    {
        return toAjax(dsSpecialregionService.deleteDsSpecialregionBySpecialIds(specialIds));
    }



}
